-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Returning Index instead of boolean in knuth_morris_pratt (kmp) function, making it compatible with str.find(). #9083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Kindly tick the checkboxes while raising PR, see contributing guidelines beforehand. |
I have ticked the appropriate checkboxes. |
Please review the Pull request |
#9079 is also doing the same, check that first. |
Also keep your PR title descriptive, remove 9077 and add kmp in it, as viewers can understand easily. |
Meanwhile, @HetarthJain you can look into that doctest which is failing in #9079. |
for more information, see https://pre-commit.ci
I have used the doctest in the commit itself, it has passed. Please review it. |
Add these doctests there in kmp() function:
Run: |
for more information, see https://pre-commit.ci
@cclauss kindly have a look at this PR, your doctest for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add doctests because this PR had none.
Thanks @cclauss and @rohan472000 for your guidance in my first PR |
…on, making it compatible with str.find(). (TheAlgorithms#9083) * Update knuth_morris_pratt.py - changed Boolean to Index * Update knuth_morris_pratt.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update knuth_morris_pratt.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update knuth_morris_pratt.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update back_propagation_neural_network.py * Update back_propagation_neural_network.py * Update strings/knuth_morris_pratt.py * Update knuth_morris_pratt.py * Update knuth_morris_pratt.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <[email protected]>
Describe your change:
Returning the index of first occurrence of a match in knuth_morris_pratt algorithm. The return type is converted from boolean to int. The function name parameters are aligned to Python naming conventions.
Fixes #9077
Checklist: